package com.asset.dispoal.evidenceconfig;

import com.asset.dispoal.evidenceconfig.api.BsEvidenceConfItemService;
import com.asset.dispoal.evidenceconfig.dto.request.BsEvidenceConfItemRequest;
import com.asset.dispoal.evidenceconfig.dto.response.BsEvidenceConfItemResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import tech.mhuang.pacebox.springboot.core.controller.BaseController;
import tech.mhuang.pacebox.springboot.protocol.Result;
import tech.mhuang.pacebox.springboot.protocol.data.PageVO;

import java.util.List;


/**
 * @author qr
 * @date 2021/10/21$
 */
@RestController
@Api(value = "证据打包配置分类管理", tags = "证据打包配置分类管理")
@RequestMapping("/bs/evidenceConfItem")
public class BsEvidenceConfItemController extends BaseController {

    @Autowired
    private BsEvidenceConfItemService bsEvidenceConfItemService;


    @ApiOperation(value = "通用查询（分页）")
    @GetMapping("/queryByConfId")
    public Result<PageVO<BsEvidenceConfItemResponse>> queryByConfId(BsEvidenceConfItemRequest bsEvidenceConfItemRequest) {
        return Result.ok(bsEvidenceConfItemService.queryByConfId(bsEvidenceConfItemRequest));
    }

    @ApiOperation(value = "根据id查询列表")
    @GetMapping("/queryIdsByTable")
    public Result<List<BsEvidenceConfItemResponse>> queryIdsByTable(@RequestParam("ids") List<String> ids) {
        return bsEvidenceConfItemService.queryIdsByTable(ids);
    }

    @ApiOperation(value = "修改/添加")
    @PostMapping("/insertOrUpdate")
    public Result insertOrUpdate(@RequestBody BsEvidenceConfItemRequest bsEvidenceConfItemRequest) {
        bsEvidenceConfItemService.insertOrUpdateAll(bsEvidenceConfItemRequest);
        return Result.ok();
    }

    @ApiOperation(value = "删除")
    @PostMapping("/del")
    public Result del(@RequestBody BsEvidenceConfItemRequest bsEvidenceConfItemRequest) {
        bsEvidenceConfItemService.del(bsEvidenceConfItemRequest);
        return Result.ok();
    }
}